package com.droidski.taskdb.model.impl;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.Set;

import com.droidski.taskdb.model.Tag;
import com.droidski.taskdb.model.Task;

public class TagImpl implements Tag, Serializable {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1;
	
	private static final long VERSION = 1;
	
	String text;
	Set<Task> tasks;

	@Override
	public Set<Task> getTasks() {
		return tasks;
	}

	public void setTasks(Set<Task> tasks) {
		this.tasks = tasks;
	}

	@Override
	public String getText() {
		return text;
	}
	
	 private void readObject(ObjectInputStream aInputStream
	   ) throws ClassNotFoundException, IOException {
	     //always perform the default de-serialization first
		   long thisVersion = aInputStream.readLong();
		   if ( thisVersion == serialVersionUID ) {
			   aInputStream.defaultReadObject();
		   }

	  }

	    private void writeObject(
	      ObjectOutputStream aOutputStream
	    ) throws IOException {
	      //perform the default serialization for all non-transient, non-static fields
	    	aOutputStream.writeLong(serialVersionUID);
	      aOutputStream.defaultWriteObject();
	    }
	    
}
